<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- Import style -->
    <script src="https://unpkg.com/vue@next"></script>
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-plus"></script>
</head>
<body>
<div id="app">
    用户名：<el-input v-model="username" placeholder="请输入用户名"></el-input>
    密码：<el-input v-model="password" placeholder="请输入密码"></el-input>
    <el-button type="primary" @click="login">登录</el-button>
</div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    const App = {
        data() {
            return {
                message: 'Hello Vue!',
                username: "",
                password: ""
            }
        },
        methods:{
            login(){
                axios.post(`/login?username=${this.username}&password=${this.password}`).then(res=>{
                    if(res.data === "success"){
                        this.$message.success("login ok!");
                    }else{
                        this.$message.error("用户名或密码错误，登录失败！")
                    }
                })
            }
        }
    };
    const app = Vue.createApp(App);
    app.use(ElementPlus);
    app.mount("#app");
</script>
</body>
</html>